<?php
$adm_menu = "1";

include("config.php");
if (!isset($_SESSION["auser"]) || $_SESSION["auser"] == "" || $_SESSION['agroup'] != "WEB_ADMIN") header('Location: index.php');


$db_www = new DB($server_username,$server_pass,$server_db,$server,$driver);

$err = "";
if (isset($_REQUEST["clearmsg"])){
	$sql = "UPDATE n60_asm SET n60_skyrius='' WHERE N60_KODAS_SM='".addslashes_mssql($_REQUEST["code"])."'";
	$db_www->execute($sql);
}
if (isset($_REQUEST["findim"])){
		$test_q = "SELECT N08_kodas_ks,N08_PAV FROM n08_klij WHERE N08_kodas_ks = '".$_REQUEST["imcode"]."'";
		//echo $test_q; 
		$im = $db_www->returnInfo($test_q);	
		if ($im == null) {
			$impav = "";
			$uid = "";
			$err .= "<br>Nerasta įmonė su tokiu kodu!";
		} else {
			$impav = $im["N08_PAV"];
			$uid = $_REQUEST["imcode"];
		}
}
if (isset($_REQUEST["key"])){
	$key = trim($_REQUEST["key"]);
	$_SESSION["searchkey"] = $key;
} else {
	if (isset($_SESSION["searchkey"])) {
		$key = $_SESSION["searchkey"];
	} else {
		$key = "";
	}
}

if (isset($_REQUEST["act"]) && !isset($_REQUEST["clearmsg"]) && !isset($_REQUEST["findim"])){
	if ($_REQUEST["act"] == "block") {
		$ustatus_query = str_replace("<kodas>", addslashes_mssql($_REQUEST["code"]), $ustatus_query);
		$ustatus_query = str_replace("<status>", "1", $ustatus_query);
		$db_www->execute($ustatus_query);		
	} else if ($_REQUEST["act"] == "unblock") {
		$ustatus_query = str_replace("<kodas>", addslashes_mssql($_REQUEST["code"]), $ustatus_query);
		$ustatus_query = str_replace("<status>", "0", $ustatus_query);
		$db_www->execute($ustatus_query);		
	} else if ($_REQUEST["act"] == "save") {		
		//ar yra toks imones kodas
		$test_q = "SELECT N08_kodas_ks,N08_PAV FROM n08_klij WHERE N08_kodas_ks = '".$_REQUEST["imcode"]."'";
		$im = $db_www->returnInfo($test_q);		
		if (empty($im)) {
			$err .= "<br>Nerasta įmonė su tokiu kodu!";
		}
		//ar ivestas slaptazodis
		if (trim($_REQUEST["pass"])==""){
			$err .= "<br>Neįvestas slaptažodis!";
		}
		//ar ivestas vartotojo id
		if (trim($_REQUEST["uid"])==""){
			$err .= "<br>Neįvestas vartotojo id!";
		}
		//ar teisingas el pastas
		if(!filter_var($_REQUEST["email"], FILTER_VALIDATE_EMAIL))
		{
			$err .= "<br>Neteisingas el. pašto adresas!";
		}
		if ($_REQUEST["code"] == "0") { //naujas		
			//ar dar nera vartotojo su tokiu vartotojo id
			
			$test_q = "SELECT * FROM n60_asm WHERE n60_kodas_sm = '".$_REQUEST["uid"]."' AND n60_kodas_gs='WEB'";
			$usr = $db_www->returnInfo($test_q);		
			if (!empty($usr)) {
				$err .= "<br>Vartotojas su tokiu id jau egzistuoja!";
			}			
			//jei nebuvo klaidu
			if ($err == ""){
				$sql = "exec web_insert_user
				@n60_kodas_sm='".iconv('UTF-8','windows-1257', addslashes_mssql($_REQUEST["uid"]))
				."',@n60_kodas_ks='".addslashes_mssql($im["N08_kodas_ks"])
				."',@n60_pav2='". addslashes_mssql($im["N08_PAV"])
				."',@n60_pareigos='".iconv('UTF-8','windows-1257', addslashes_mssql($_REQUEST["pass"]))
				."',@n60_vardas='".iconv('UTF-8','windows-1257', addslashes_mssql($_REQUEST["firstname"]))
				."',@n60_pav='".iconv('UTF-8','windows-1257', addslashes_mssql($_REQUEST["lastname"]))
				."',@n60_e_mail='".addslashes_mssql($_REQUEST["email"])."';";
				$db_www->execute($sql);
				//echo $sql;
				$_REQUEST["poz"] = "all";
			}
		} else { //redagavimas
			//jei nebuvo klaidu
			if ($err == ""){				
				$sql = "UPDATE n60_asm SET n60_kodas_ks='".addslashes_mssql($im["N08_kodas_ks"])
				."',n60_pav2='". addslashes_mssql($im["N08_PAV"])
				."',n60_pareigos='".iconv('UTF-8','windows-1257', addslashes_mssql($_REQUEST["pass"]))
				."',n60_vardas='".iconv('UTF-8','windows-1257', addslashes_mssql($_REQUEST["firstname"]))
				."',n60_pav='".iconv('UTF-8','windows-1257', addslashes_mssql($_REQUEST["lastname"]))
				."',n60_e_mail='".addslashes_mssql($_REQUEST["email"])
				."' "." WHERE N60_KODAS_SM='".addslashes_mssql($_REQUEST["code"])."'";
				$db_www->execute($sql);
				//echo $sql;
				$_REQUEST["poz"] = "all";					
			}			
		}
	}
}	
include("header.php");
include("menu.php");

if (isset($_REQUEST["poz"])){
	if ($_REQUEST["poz"] != "new" && $_REQUEST["poz"] != "edit" && $_REQUEST["poz"] != "all") {
		$poz = "all";
	} else {
		$poz = $_REQUEST["poz"];
	}
} else {
	$poz = "all";
}

?>
<SCRIPT language="JavaScript">
<!--
function unhide() {
	el = document.getElementById('poz');
	el.value = 'new';
	el = document.getElementById('uid');
	el.value = '';
	el = document.getElementById('code');
	el.value = '0';
	el = document.getElementById('imcode');
	el.value = '';
	el = document.getElementById('impav');
	el.value = '';
	el = document.getElementById('pass');
	el.value = '';
	el = document.getElementById('firstname');
	el.value = '';
	el = document.getElementById('lastname');
	el.value = '';	
	el = document.getElementById('email');
	el.value = '';


	but = document.getElementById('newbut');
	form = document.getElementById('newform');
	but.style.display = 'none';
	form.style.display = 'inline';
}

function hide() {
	but = document.getElementById('newbut');
	form = document.getElementById('newform');
	but.style.display = 'inline';
	form.style.display = 'none';
}

function status(n,nr)
{
    if (n == "1") {
		var answer = confirm("Ar blokuoti vartotoją?")
		if (answer){
			window.location='users.php?act=block&code='+nr ;
		}
	} else {
		var answer = confirm("Ar atblokuoti vartotoją?")
		if (answer){
			window.location='users.php?act=unblock&code='+nr ;
		}
	}	
}

function getRandomNum(lbound, ubound) {
return (Math.floor(Math.random() * (ubound - lbound)) + lbound);
}

function getRandomChar(number, lower, upper, other, extra) {
var numberChars = "0123456789";
var lowerChars = "abcdefghijklmnopqrstuvwxyz";
var upperChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var otherChars = "`~!@#$%^&*()-_=+[{]}\\|;:'\",<.>/? ";
var charSet = extra;
if (number == true)
charSet += numberChars;
if (lower == true)
charSet += lowerChars;
if (upper == true)
charSet += upperChars;
if (other == true)
charSet += otherChars;
return charSet.charAt(getRandomNum(0, charSet.length));
}

function getPassword(length, extraChars, firstNumber, firstLower, firstUpper, firstOther,
latterNumber, latterLower, latterUpper, latterOther) {
var rc = "";
if (length > 0)
rc = rc + getRandomChar(firstNumber, firstLower, firstUpper, firstOther, extraChars);
for (var idx = 1; idx < length; ++idx) {
rc = rc + getRandomChar(latterNumber, latterLower, latterUpper, latterOther, extraChars);
}
return rc;
}

function generate(){	
	document.forma.pass.value = getPassword(8,true,true,true,true,false,true,true,true,false);
}

    $(document).ready(function() { 
 
        $('#blockButton').click(function() { 
            $('#test1').block({ message: null, 
									overlayCSS:  { 
										backgroundColor: '#000', 
										opacity:         0.4, 
										cursor:          'wait' 
									}

			}); 
        }); 
 
        $('#unblockButton').click(function() { 
            $('#test1').unblock(); 
        }); 
		
		$('#test').on('click', 'tr', function () {
			var state = $(this).hasClass('highlighted');
			$('.highlighted').removeClass('highlighted');
			if ( ! state) { $(this).addClass('highlighted'); 
				url = 'save_sel.php?code='+$(this).attr('id').substring(1)+'&rand='+Math.random();
			} else {
				url ='save_sel.php?code=0'+'&rand='+Math.random();
			}
		    try {
            var _img = new Image();
            _img.src = url;
        } catch (e) { }
		});
		
		
 <?php
 if (!isset($oldstyle) || $oldstyle != "1") {
 	if (($poz == "edit") || (isset($_REQUEST["act"]) && $_REQUEST["act"]=="save") ) {	
		
 ?>
			$('#test1').block({ message: null, 
									overlayCSS:  { 
										backgroundColor: '#000', 
										opacity:         0.4, 
										cursor:          'wait' 
									}

			});
			<?php
			}
			}
			?>
    });
	
	
	

//-->
</SCRIPT>
<style>
.highlighted {    
    background-color: #f5f5f5 !important;
}
</style>
<?php
if (!isset($oldstyle) || $oldstyle != "1") {
	if ($poz == "all") {
		$poz = "new";
	}
}

if ($poz == "new" || $poz == "edit") {
	if (isset($_REQUEST["code"]) && $_REQUEST["code"] != "0") {
		$code = $_REQUEST["code"];
		$uid = $code;		
		if (isset($_REQUEST["uid"])) {
			$sql = str_replace("<kodas>", addslashes_mssql($_REQUEST["uid"]), $uinfo_query);
		} else {
			$sql = str_replace("<kodas>", addslashes_mssql($uid), $uinfo_query);
		}
		//echo $uinfo_query;
		$u = $db_www->returnInfo($sql);
		if ($u == null) die("nerastas vartotojas");
		if (!isset($impav)){
			$impav = $u["n60_pav2"];		
		}
		$msg = $u["n60_poz_date"];

		if (!isset($_REQUEST["imcode"])) {
			$imcode = trim($u["n60_kodas_ks"]);			
		} else {
			$imcode = $_REQUEST["imcode"];			
		}
		if (!isset($_REQUEST["pass"])) {
			$pass = iconv('windows-1257','UTF-8', trim($u["n60_pareigos"]));			
		} else {
			$pass = $_REQUEST["pass"];			
		}	
		if (!isset($_REQUEST["firstname"])) {
			$firstname = iconv('windows-1257','UTF-8',trim($u["n60_vardas"]));			
		} else {
			$firstname = $_REQUEST["firstname"];			
		}	
		if (!isset($_REQUEST["lastname"])) {
			$lastname = iconv('windows-1257','UTF-8',trim($u["n60_pav"]));			
		} else {
			$lastname = $_REQUEST["lastname"];			
		}
		if (!isset($_REQUEST["email"])) {
			$email =trim($u["n60_e_mail"]);			
		} else {
			$email = $_REQUEST["email"];			
		}	
	} else {
		$code = "0";
		if (!isset($_REQUEST["imcode"])) {
			$imcode = "";		
		} else {
			$imcode = $_REQUEST["imcode"];			
		}
		if (!isset($uid)) {
			if (!isset($_REQUEST["uid"])) {
				$uid = "";		
			} else {
				$uid = $_REQUEST["uid"];			
			}		
		}
		if (!isset($_REQUEST["pass"])) {
			$pass = "";			
		} else {
			$pass = $_REQUEST["pass"];			
		}	
		if (!isset($_REQUEST["firstname"])) {
			$firstname = "";			
		} else {
			$firstname = $_REQUEST["firstname"];			
		}	
		if (!isset($_REQUEST["lastname"])) {
			$lastname = "";		
		} else {
			$lastname = $_REQUEST["lastname"];			
		}
		if (!isset($_REQUEST["email"])) {
			$email = "";		
		} else {
			$email = $_REQUEST["email"];			
		}			
	}
	
}

if (isset($oldstyle) && $oldstyle == "1") {
	$f = "<br><br>";
	$f .= "<div style=\"border-left:1px solid #000000;\">Veiksmai<br><br>";
	$f .= "<input class=\"but\" type=button onClick=\"parent.location='users.php?poz=new'\" value='Naujas'><br>";
	$f .= "</div>";
	
	if ($poz == "new" || $poz == "edit") {
		if ($poz == "new") {	
			$d = "Naujas vartotojas";	
		} else if ($poz == "edit") {	
			$d = "Vartotojo redagavimas";		
		} 
		
		$d .= '<table width="100%" border = "0">';
		$d .= '<tr><td align="center">';

		if ($err != ""){
			$d .= "<p style='color:red;font-weight:bold;'>".$err."</p>";
		}

		$d .= '<form name="forma" method="get" action="users.php?act=save">';
		$d .= '<input type="hidden" name="poz" value="' . $poz . '">';
		$d .= '<input type="hidden" name="code" value="' . $code . '">';
		$d .= '<table>';
		$d .= '<tr><td class="field">Įmonės kodas:</td><td><input type="text" name="imcode" value="' . $imcode . '">&nbsp;<input type="submit" name="findim" value="Ieškoti"></td></tr>';
		$d .= '<tr><td class="field">Įmonės pavadinimas:</td><td><input id="impav" style="width:300px;" type="text" name="pav" value="' . htmlspecialchars(@iconv('windows-1257', 'UTF-8',$impav), ENT_QUOTES) . '" readonly="readonly"></td></tr>';
		$d .= '<tr><td class="field">Vartotojo id:</td><td><input type="text" name="uid" value="' . $uid . '"'; 
		if ($code != "0") 
			$d .= 'readonly="readonly"'; 
		$d .= '>'; 
		if ($code != "0") {
			$d .= '<A href="nauja.php?id=' . $uid . '&p=' . md5(trim($pass)) . '" target="_blank">Kliento sistema</A>'; 
		} 
		$d .= '</td></tr>';
		$d .= '<tr><td class="field">Slaptažodis:</td><td><input id="pass" type="text" name="pass" value="' . htmlspecialchars($pass, ENT_QUOTES) . '"><A href="javascript:generate()">Generuoti</A></td></tr>';
		$d .= '<tr><td class="field">Vardas:</td><td><input type="text" name="firstname" value="' . $firstname . '"></td></tr>';
		$d .= '<tr><td class="field">Pavardė:</td><td><input type="text" name="lastname" value="' . $lastname . '"></td></tr>';
		$d .= '<tr><td class="field">El. paštas:</td><td><input type="text" name="email" value="' . $email . '"></td></tr>';
	
		if ($code != "0") {	
			$d .= "<tr><td class=\"field\">Pask. pranešimas:</td><td>" . @iconv('windows-1257', 'UTF-8',$msg) . " <input type=\"submit\" name=\"clearmsg\" value=\"Išvalyti\"></td></tr>";
		}
	
		$d .= '<tr><td colspan="2" align="center"><br><input type="submit" value="Išsaugoti"/>&nbsp;<input type="button" onclick="parent.location=\'users.php\';" value="Atgal"></td></tr>';
		$d .= '</table>';
		$d .= '</form>';
		$d .= '</td></tr></table>';		
		
	} else {	
		$d = "Visi vartotojai";	
		$users = $db_www->returnList($allusers_query);	
	}
	
} else {
	if(!isset($poz)) {
		$poz = "new";
		$code = "0";
	}
	
	if ($poz == "edit") {	
		$tit = "Vartotojo redagavimas";		
		$disp = "";
		$disp2 = "display:none;";
	} else {
		$tit = "Naujas vartotojas";
		$disp = "display:none;";
		$disp2 = "";
	}
	if (isset($_REQUEST["act"]) && $_REQUEST["act"]=="save") {
		$disp = "";
		$disp2 = "display:none;";
	}
	$f = "";
	$f .= "<form method=\"post\" name='forma' action='users.php?act=save'>";
	$f .= '<input id="poz" type="hidden" name="poz" value="' . $poz . '">';
	$f .= '<input id="code" type="hidden" name="code" value="' . $code . '">';
	$f .= "<table id='newform' cellspacing='0' cellpadding='5' class='params' style='". $disp ."'>";
	$f .= "<tr><th class='head'>" . $tit . "</th></tr>";
	if ($err != ""){
			$f .= "<tr><td style='padding-right:20px;'><p style='background-color:transparent;color:red;font-weight:bold;font-size:10px;'>".$err."</p></td></tr>";
	}	
	$f .= "<tr><th>Įmonės kodas:</th></tr>";
	$f .= "<tr><td style='text-align:left;'><input id='imcode' class=\"inp\" type='text' name=\"imcode\" value=\"" . htmlspecialchars($imcode) . "\"></td></tr>";
	$f .= "<tr><td style='padding-right:20px;'><A class='flink' href=\"#\" onclick='document.forma.action=\"users.php?act=save&findim=1\";document.forma.submit()'>Ieškoti</A></td></tr>";
	$f .= "<tr><th>Įmonės pavadinimas:</th></tr>";
	$f .= "<tr><td style='text-align:left;'><input id='impav' class=\"inp\" type='text' name=\"pav\" value=\"" . htmlspecialchars(@iconv('windows-1257', 'UTF-8',$impav), ENT_QUOTES) . "\" readonly=\"readonly\"></td></tr>";	
	$f .= "<tr><th>Vartotojo ID:</th></tr>";
	$f .= "<tr><td style='text-align:left;'><input id='uid' class=\"inp\" type='text' name=\"uid\" value=\"" . htmlspecialchars($uid) . '"'; 
	if ($code != "0") 
		$f .= ' readonly="readonly"'; 
	$f .= "\"></td></tr>";
	$f .= "<tr><th>Slaptažodis:</th></tr>";
	$f .= "<tr><td style='text-align:left;'><input id=\"pass\" class=\"inp\" type='text' name=\"pass\" value=\"" . htmlspecialchars($pass, ENT_QUOTES) . "\"></td></tr>";
	$f .= "<tr><td style='padding-right:20px;'><A class='flink' href=\"javascript:generate()\">Generuoti</A></td></tr>";
	$f .= "<tr><th>Vardas:</th></tr>";
	$f .= "<tr><td style='text-align:left;'><input id='firstname' class=\"inp\" type='text' name=\"firstname\" value=\"" . htmlspecialchars($firstname) . "\"></td></tr>";	
	$f .= "<tr><th>Pavardė:</th></tr>";
	$f .= "<tr><td style='text-align:left;'><input id='lastname' class=\"inp\" type='text' name=\"lastname\" value=\"" . htmlspecialchars($lastname) . "\"></td></tr>";
	$f .= "<tr><th>El. paštas:</th></tr>";
	$f .= "<tr><td style='text-align:left;'><input id='email' class=\"inp\" type='text' name=\"email\" value=\"" . htmlspecialchars($email) . "\"></td></tr>";
	$f .= "<tr><td style='text-align:center;'><table border='0'cellspacin='0' cellpadding='0'><tr><td style='text-align:left;padding:0;width:50px;'>";
	$f .= "<Button id='unblockButton' class='but bgfilter nopad' onclick=\"hide();return false;\">Atgal</Button>";
	$f .= "</td><td align='right' style='padding:0;width:80px;'>";
	$f .= "<input class='but bgfilter nopad' type = \"submit\" value = \"Išsaugoti\">";
	$f .= "</td></tr></table>";
	$f .= "</td></tr>";
	$f .= "</table></form>";
	$f .= "<table id='newbut' cellspacing='0' cellpadding='5' class='params' style='".$disp2."'>";
	$f .= "<tr><td style='text-align:center;'><A id='blockButton' onclick='unhide();' class='card3'>Sukurti naują vartotoją</A></td></tr>";
	$f .= "</table><br>";	
	$f .= "<table cellspacing='0' cellpadding='5' class='params'>";
	$f .= "<tr><td style=''><br><form method=\"get\" action='users.php?act=search'>";
	$f .= "<input id='key' class=\"inp\" onfocus=\"this.value='';\" type='text' name=\"key\" value=\"";
	if ($key != "")
		$f .= htmlspecialchars($key);
	else
		$f .= "Paieška";
	$f .= "\"></br>";
	$f .= "</form></td></tr>";
	$f .= "</table>";	
	
	$d = "";
	if ($key == "") {
		$allusers_query = str_replace("<filter>", "", $allusers_query);
	} else {
		$key = iconv('UTF-8','windows-1257',addslashes_mssql($key));
		$filter = "AND (n60_kodas_sm LIKE '%$key%' OR n60_e_mail LIKE '%$key%' OR n60_pav2 LIKE '%$key%')";
		$allusers_query = str_replace("<filter>", $filter, $allusers_query);
	}	
	$users = $db_www->returnList($allusers_query);
}

if (isset($users) && !empty($users)) {

$d .= '<table width="100%" border = "0">';
$d .= '<tr><td align="center">';
$d .= '<table id="test" cellspacing="0" cellpadding="3" class="innercont2">';

if (isset($oldstyle) && $oldstyle == "1") {
	foreach ($users as $user) {
		$d .= "<tr><td align='right' width='130'>";
		if ($user["n60_poz_date"] != "1") {
			$d .= "<A onclick=\"status('1','".@iconv('windows-1257', 'UTF-8', trim($user["n60_kodas_sm"]))."');\"><img src='img/green.gif' alt='' title=''></A>";
		} else {
			$d .= "<A onclick=\"status('0','".@iconv('windows-1257', 'UTF-8', trim($user["n60_kodas_sm"]))."');\"><img src='img/red.gif' alt='' title=''></A>";
		}
		$d .= "</td><td width='120'><A href='users.php?poz=edit&code=".@iconv('windows-1257', 'UTF-8', trim($user["n60_kodas_sm"]))."' class='card'>".trim($user["n60_kodas_sm"])."</A></td><td>".@iconv('windows-1257', 'UTF-8', htmlspecialchars($user["n60_e_mail"]))."</td><td>".@iconv('windows-1257', 'UTF-8', htmlspecialchars($user["n60_pav2"]))."</td><td>".@iconv('windows-1257', 'UTF-8', htmlspecialchars($user["n60_skyrius"]))."</td>";
		$d .= "<td width='120'><A href='nauja.php?id=".trim($user["n60_kodas_sm"])."&p=".md5(trim($user["n60_pareigos"]))."' target='_blank'>Kliento sistema</A></td>";
		$d .= "<td width='30'><A href='alog.php?uid=".trim($user["n60_kodas_sm"])."'>Log</A></td>";
		$d .= "</tr>\n";
	}
} else {
		$d .= '<tr><th>Pask. pranešimas</th><th>Vartotojo ID</th><th>Pavadinimas</th><th>El. paštas</th><th colspan="3">Blokuoti</th></tr>';

	foreach ($users as $user) {
		$uid = @iconv('windows-1257', 'UTF-8', trim($user["n60_kodas_sm"]));
		if (isset($_SESSION["sel_user"]) && ($_SESSION["sel_user"] == $uid)) { 
			$d .= "<tr id='r".$uid."' class='highlighted'>";
		} else {
			$d .= "<tr id='r".$uid."' >";
		}	
		$d .= "<td><A href='user.php?ret=users&code=".$uid."' class='card'>".@iconv('windows-1257', 'UTF-8', htmlspecialchars($user["n60_skyrius"]))."</A></td>";
		$d .= "<td><A href='user.php?ret=users&code=".$uid."' class='card'>".trim($user["n60_kodas_sm"])."</A></td>";
		$d .= "<td><A href='user.php?ret=users&code=".$uid."' class='card'>".@iconv('windows-1257', 'UTF-8', htmlspecialchars($user["n60_pav2"]))."</A></td>";
		$d .= "<td><A href='user.php?ret=users&code=".$uid."' class='card'>".@iconv('windows-1257', 'UTF-8', htmlspecialchars($user["n60_e_mail"]))."</A></td>";
		$d .= "<td class='cent' nowrap>";
		if ($user["n60_poz_date"] != "1") {
			$d .= "<A onclick=\"status('1','".@iconv('windows-1257', 'UTF-8', trim($user["n60_kodas_sm"]))."');\"><img src='img/green_new.gif' alt='' title=''></A>";
		} else {
			$d .= "<A onclick=\"status('0','".@iconv('windows-1257', 'UTF-8', trim($user["n60_kodas_sm"]))."');\"><img src='img/red_new.gif' alt='' title=''></A>";
		}
		$d .= "&nbsp;&nbsp;<A class='card' href='alog.php?uid=".trim($user["n60_kodas_sm"])."'>Log</A>";
		$d .= "&nbsp;&nbsp;<A class='card2' href='nauja.php?id=".trim($user["n60_kodas_sm"])."&p=".md5(trim($user["n60_pareigos"]))."' target='_blank'>Kliento sistema</A></td>";
		$d .= "</tr>\n";
	}
	$d .= "<tr><td colspan='7' style='text-align:right;'><img src='img/green_new.gif' alt='' title=''> - Aktyvūs vartotojai <img src='img/red_new.gif' alt='' title=''> - Blokuoti vartotojai</td></tr>";
}

$d .= '</table>';
$d .= '</td>';
$d .= '</tr></table>';

}


?>

<table class="innercont" cellspacing="0" cellpadding="10">
<tr><td class="leftcol">

<?php
if (isset($oldstyle) && $oldstyle == "1") {
	echo $d;
} else {
	echo $f;
}
?>
</td>
<td class="rightcol" rowspan="2">
<?php
if (isset($oldstyle) && $oldstyle == "1") {
	echo $f;
} else {
	echo $d;
}
?>
</td>
</tr>
<tr><td >

</td></tr>
</table>
<?php
include("footer.php");
?>